<?php
/**
 * 静的ファイルレンダリングクラス
 * 
 * @author tanaka
 * @package Controller
 * @subpackage Pages
 */
class PagesController extends Controller_Action
{
	public function indexAction()
	{
		$this->_setViewLayoutFile('nomenu');
		$pathes = explode('/', $_SERVER['REDIRECT_URL']);
		
		if (count($pathes) && $pathes[count($pathes)-1] === "") {
			$pathes[count($pathes)-1] = "index";
		}
		$pathes = preg_grep('/^\w+$/', $pathes);
		
		if(reset($pathes) != "pages"){
			array_unshift($pathes, "pages");
		}
		
		$templatePath = implode('/', $pathes);
		$templatePath .= ".tpl";
		
		/** @var Zend_Controller_Action_Helper_ViewRenderer */
		$vr = $this->_helper->viewRenderer;
		$base = $vr->getViewBasePathSpec() . "/";
		
		if (file_exists($base . $templatePath)) {
			$this->_helper->viewRenderer->setViewScriptPathSpec($templatePath);
		} else {
			$this->_throw404Error("Template Not Found [$base][$templatePath]");
		}
	}
}